<template>
  <div class="app-container">
    <p>新/老客户管理</p>
    <div class="radio">
      <div>
        <span>自动标记老客：</span>
        <span>
          <el-radio v-model="radio" :label="1">开启</el-radio>
          <el-radio v-model="radio" :label="2">关闭</el-radio>
        </span>
        <p>开启后用户成功下单任意商品即自动标记为您的老客。您可以在【用户列表】中将他手动调整为新客。</p>
      </div>
    </div>
    <div style="text-align: center; padding: 15px;">
      <el-button
        size="mini"
        type="primary"
        @click="saveRule"
      >保存规则</el-button>
    </div>
  </div>
</template>

<script>
import { getRule,saveRule } from "@/api/triones/markMemeberRule";
export default {
  name: "index",
  data() {
    return {
      radio: 2
    }
  },
  created() {
    this.getRule();
  },
  methods: {
    getRule() {
      getRule().then(response => {
        this.radio = response.data.isMarkMemberToOld
      })
    },
    /** 保存规则 */
    saveRule() {
      saveRule(this.radio).then(response => {
        this.$message.success("操作成功");
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.radio {
  font-size: 14px;
  > div {
    span:nth-last-of-type(1) {
      margin-left: 100px;
    }
    p {
      padding: 5px;
      margin-left: 200px;
      background-color: #f7b500;
    }
  }
}
</style>
